package logic

import (
	"context"
	"renting/models/mysql"

	"renting/renting/internal/svc"
	"renting/renting/renting"

	"github.com/zeromicro/go-zero/core/logx"
)

type RentingShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRentingShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RentingShowLogic {
	return &RentingShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RentingShowLogic) RentingShow(in *renting.RentingShowRequest) (*renting.RentingShowResponse, error) {
	// todo: add your logic here and delete this line
	var a mysql.Renting
	mysql.DB.Debug().Where("id = ?", in.Id).Find(&a)

	return &renting.RentingShowResponse{
		Id:      int64(a.ID),
		Title:   a.Title,
		Types:   a.Types,
		Price:   a.Price,
		Address: a.Address,
	}, nil
}
